package com.hxc.orangeyule.modle;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/3/14.
 */
public class HorScrollViewContent {

    /**
     * code : 1
     * msg : 操作成功
     * data : [{"name":"推荐","flag":6},{"id":27,"name":"八卦"},{"id":26,"name":"时尚"},{"id":61,"name":"生活"},{"id":32,"name":"影视"},{"id":102,"name":"美妆"},{"id":95,"name":"互动"},{"name":"GIF","flag":12},{"name":"视频","flag":2}]
     */

    private int code;
    private String msg;
    /**
     * name : 推荐
     * flag : 6
     */

    private List<DataEntity> data;

    public static HorScrollViewContent objectFromData(String str) {

        return new com.google.gson.Gson().fromJson(str, HorScrollViewContent.class);
    }

    public static HorScrollViewContent objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new com.google.gson.Gson().fromJson(jsonObject.getString(str), HorScrollViewContent.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<HorScrollViewContent> arrayHorScrollViewContentFromData(String str) {

        Type listType = new com.google.gson.reflect.TypeToken<ArrayList<HorScrollViewContent>>() {
        }.getType();

        return new com.google.gson.Gson().fromJson(str, listType);
    }

    public static List<HorScrollViewContent> arrayHorScrollViewContentFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new com.google.gson.reflect.TypeToken<ArrayList<HorScrollViewContent>>() {
            }.getType();

            return new com.google.gson.Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setData(List<DataEntity> data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public List<DataEntity> getData() {
        return data;
    }

    public static class DataEntity {
        private String name;
        private int flag;

        public static DataEntity objectFromData(String str) {

            return new com.google.gson.Gson().fromJson(str, DataEntity.class);
        }

        public static DataEntity objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new com.google.gson.Gson().fromJson(jsonObject.getString(str), DataEntity.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataEntity> arrayDataEntityFromData(String str) {

            Type listType = new com.google.gson.reflect.TypeToken<ArrayList<DataEntity>>() {
            }.getType();

            return new com.google.gson.Gson().fromJson(str, listType);
        }

        public static List<DataEntity> arrayDataEntityFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new com.google.gson.reflect.TypeToken<ArrayList<DataEntity>>() {
                }.getType();

                return new com.google.gson.Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public void setName(String name) {
            this.name = name;
        }

        public void setFlag(int flag) {
            this.flag = flag;
        }

        public String getName() {
            return name;
        }

        public int getFlag() {
            return flag;
        }
    }
}
